<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <script>
        var msg = '${msg}'
        if(msg){
            alert(msg)
        }

    </script>
</head>
<body>
<h1 style="color:red;"><marquee>欢迎来到网络商城管理系统</marquee></h1>
<c:if test="${empty user}">
    <a href="${pageContext.request.contextPath}/jsp/register.jsp">注册</a>
    <a href="${pageContext.request.contextPath}/jsp/login.jsp">登录</a>
</c:if>
<c:if test="${not empty user}">
    欢迎您:${user.username}
    <a href="${pageContext.request.contextPath}/logout.user">注销</a>
    <a href="${pageContext.request.contextPath}/findMyOrders.order">我的订单</a>
</c:if>
<hr/>
<table border="1">
    <tr>
        <th>序号</th>
        <th>商品名称</th>
        <th>商品单价</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${products}" var="p" varStatus="status">
        <tr>
            <td>${status.count}</td>
            <td>${p.name}</td>
            <td>${p.price}</td>
            <td>
                <a href="${pageContext.request.contextPath}/add.cart?id=${p.id}">加入购物车</a>
            </td>
        </tr>
    </c:forEach>

</table>
<c:if test="${not empty user}">
    <a href="${pageContext.request.contextPath}/jsp/cart.jsp">查看购物车</a>
</c:if>
</body>
</html>